package com.jiangnan.repository

import com.jiangnan.api.client.ApiClient
import com.jiangnan.api.client.BookApiClient
import com.jiangnan.entity.LoginInfo
import com.jiangnan.entity.Res
import com.jiangnan.entity.User
import com.jiangnan.entity.UserBorrowCertificate
import okhttp3.MultipartBody
import retrofit2.Response

class UserRepository {

    /**
     * 修改用户信息
     */
    suspend fun updateUserInfo(userId: Int, userInfo: LoginInfo) : Res<String> {
        return BookApiClient.userApiService.updateUserInfo(userId, userInfo)
    }

    /**
     * 上传头像
     */
    suspend fun uploadAvatarImage(filePart: MultipartBody.Part) : Response<Res<String>> {
        return BookApiClient.userApiService.uploadImage(filePart)
    }

    suspend fun fetchUser(userId: Long): Res<User> {
        return BookApiClient.userApiService.getUserById(userId)
    }

    suspend fun fetchUserCertificate(userId: Long): Res<UserBorrowCertificate> {
        return BookApiClient.userApiService.getCertificateById(userId)
    }


}